import { Injectable } from '@angular/core';
// import { API_URL } from '../const/base.const';
import { HttpService } from './http.service';
import { API_URL } from '../const/base.const';
import { TSortData } from 'src/app/pages/types';

@Injectable({
  providedIn: 'root',
})
export class CaseService {
  constructor(private $http: HttpService) {}

  getCases(fid: number) {
    return this.$http.get(API_URL.CASE + '/' + fid);
  }

  getCaseById(id: number) {
    return this.$http.get(`${API_URL.CASE}/${id}`);
  }

  //保存数据
  postCase(data: any) {
    return this.$http.post(API_URL.CASE, data);
  }

  updateCase(id: number, data: any) {
    return this.$http.patch(`${API_URL.CASE}/${id}`, data);
  }

  deleteCase(id: number) {
    return this.$http.delete(`${API_URL.CASE}/${id}`);
  }

  updateCaseSort(payload: TSortData[]) {
    return this.$http.post(`${API_URL.CASE}/updateSort`, payload);
  }

  // 复制case
  copyCase(id: number) {
    return this.$http.get(`${API_URL.CASE}/copy/${id}`);
  }
}
